//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.dao.wills;

import com.aidong.dao.wills.BaseDao;
import com.aidong.model.wills.Upload;
import com.aidong.util.FuncUtil;
import org.springframework.stereotype.Repository;

@Repository
public class UploadDao extends BaseDao<Upload, Integer> {
	public UploadDao() {
	}

	public Upload getByMd5(String md5) {
		return (Upload)this.getByWhere("fileMd5=:p1", new Object[]{md5});
	}

	public void addUpload(Upload file) {
		this.add(file);
		String pid = "000" + file.getFileId();
		String url = file.getFileId().intValue() / 1000 + 1001 + "/" + FuncUtil.getRandNumStr(3) + pid.substring(pid.length() - 3);
		file.setUrl(url + "." + file.getExt());
		this.update(file);
	}
}
